package com.jzoffer2;

import java.util.Scanner;

/**
 * TODO
 *
 * @author lefly
 * @version 1.0
 * @classname No49
 * @description 丑数
 * @date 2021/3/8 下午6:06
 */
public class No49 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();
        int res = nthUglyNumber(input);
        System.out.println(res);
        sc.close();

    }

    public static int nthUglyNumber(int n) {
        if(n <= 1){
            return n;
        }
        int[] uglyNum = new int[n];
        uglyNum[0] = 1;
        int k = 1,i2 = 0,i3 = 0,i5 = 0;
        while (k < n){
            uglyNum[k] = Math.min(uglyNum[i2] * 2,Math.min(uglyNum[i3] * 3,uglyNum[i5] * 5));
            if(uglyNum[i2] * 2 == uglyNum[k]){
                i2++;
            }
            if(uglyNum[i3] * 3 == uglyNum[k]){
                i3++;
            }
            if(uglyNum[i5] * 5 == uglyNum[k]){
                i5++;
            }
            k++;
        }
        return uglyNum[n - 1];

    }

}
